package org.hansk.wg.core.data
{
	/**
	 * @file LinkedStack.as
	 * @explain 链表
	 * @copyright it.hansk.org
	 * @author <mailto:hao.guo@it.hansk.org.com><a href="mailto:hans#hansk.org">Hans</a>[]
	 * @date 2013-8-17
	 */	
	public class LinkedStack implements IStack
	{
		
			private var top:Node;
			
			public function LinkedStack()
			{
				top = null;
			}
			/**
			 * 查看链栈是否为空 
			 * @return 
			 * 
			 */			
			public function isEmpty():Boolean
			{
				return top == null;
			}
			/**
			 * 获取栈首 
			 * @return 
			 * 
			 */			
			public function get():Object
			{
				if(!isEmpty())
				{
					return top.data;
				}
				return null;
			}
			/**
			 * 压栈 
			 * @param element
			 * @return 
			 * 
			 */			
			public function push(element:Object):Boolean
			{
				if(element == null)
					return false;
				top = new Node(element, top);
				return true;
			}
			/**
			 * 出栈 
			 * @return 
			 * 
			 */			
			public function pop():Object
			{
				if(!isEmpty())
				{
					var temp:Object = top.data;
					top = top.next;
					return temp;
				}
				return null;
			}
	}
}